<?php

namespace App\Console\Commands;

use App\Interfaces\agent\AgentInterFace;
use App\model\agent\Agent;
use App\Repository\Agent\AgentRepository;
use App\Service\MiniProgramService;
use Illuminate\Console\Command;

class AgentQrocde extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'agent:qrcode';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';
    protected $agentRepository;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(AgentInterFace $agentRepository)
    {
        $this->agentRepository=$agentRepository;
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

       Agent::chunk(100,function ($agent){
           foreach ($agent as $value){
               $this->agentRepository->getQrcode($value);
           }
       });


    }
}
